import Nav from '@/pages/Nav';
import { lazy } from 'react';
import { createBrowserRouter } from 'react-router-dom';
import type { RouteObject } from 'react-router-dom';

const Layout = lazy(() => import('@/Layout/Layout'));
const Home = lazy(() => import('@/pages/Home'));
const About = lazy(() => import('@/pages/About'));
const Docs = lazy(() => import('@/pages/Docs'));
const Note = lazy(() => import('@/pages/Note'));
const NotFound = lazy(() => import('@/pages/NotFound'));

export const routes: RouteObject[] = [
  {
    path: '/',
    element: <Layout />,
    children: [
      { index: true, element: <Home /> },
      { path: 'docs', element: <Docs /> },
      { path: 'nav', element: <Nav /> },
      { path: 'note', element: <Note /> },
      { path: 'about', element: <About /> }
    ]
  },
  {
    path: '*',
    element: <NotFound />
  }
];
export const navItems: { path: string; label: string }[] = [
  { path: '/', label: '首页' },
  { path: '/docs', label: '文档' },
  { path: '/nav', label: '导航' },
  { path: '/note', label: '随笔' },
  { path: '/about', label: '拾两' }
];

const router = createBrowserRouter(routes);

export default router;
